import { Question } from "@/api/interface/index";
import { BANK_QUESTION } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 课程模块
 */
export interface ResPage<T> {
  list: T[];
  pageNum: number;
  pageSize: number;
  total: number;
}
// 获取考试题列表
export const getBankQuestionListApi = async (params?: any) => {
  return http.post<any>(BANK_QUESTION + `/list`, params);
};

// 先创建题目，再加入到考卷
export const addQuestionWithCreateApi = async (params: Question.QuestionInfo) => {
  return http.post(BANK_QUESTION + `/add_with_create`, params);
};

// 批量把已有的题目加入到题库中
export const addQuestionBatchApi = async (params: any) => {
  return http.post(BANK_QUESTION + `/add_batch`, params);
};

// 删除题目，且从考卷中移除
export const deleteQuestionWithDestroyApi = async (params: Question.QuestionInfo) => {
  return http.post(BANK_QUESTION + `/delete_with_destroy`, params);
};

// 删除题目
export const deleteQuestionApi = async (params: Question.QuestionInfo) => {
  return http.post(BANK_QUESTION + `/delete`, params);
};

export const updateBankQuestionApi = async (params: Question.QuestionInfo) => {
  return http.post(BANK_QUESTION + `/update`, params);
};

export const sortBankQuestionApi = async (params: { data: { [p: number]: number }; bank_id: number }) => {
  return http.post(BANK_QUESTION + `/sort`, params);
};

export const exceptBankQuestionApi = async (params: any) => {
  return http.post<ResPage<Question.QuestionInfo>>(BANK_QUESTION + `/except`, params);
};

export const unionBankQuestionApi = async (params: any) => {
  return http.post<ResPage<Question.QuestionInfo>>(BANK_QUESTION + `/union`, params);
};

export const intersectBankQuestionApi = async (params: any) => {
  return http.post<ResPage<Question.QuestionInfo>>(BANK_QUESTION + `/intersect`, params);
};
